package adb;

import static adb.LoadingWindows.getJarpath;
import static adb.OSK.OSKopen;
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.MenuItem;
import java.awt.Point;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.Popup;
import javax.swing.PopupFactory;
import javax.swing.SwingWorker;
import javax.swing.Timer;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.text.DefaultCaret;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;

public final class ADBView extends FrameView {

    public static String adbVariable = "";
    public static String aaptVariable = "";
    public static String pathPCfile = "";
    public JFrame frame = this.getFrame();
    public static String command="";
    public static int loadTreeFileDeviceSuccessStatus=1;
    public static int screenShotSuccessStatus=1;
    public static int zoom = 0;
    public static int tray = 1;
    public final static Point point = new Point();
    public static PopupMenu menu;
    public static String output = "";
    public static JList listApps = new JList();
    public static String osname = System.getProperty("os.name");
    public static String separator = System.getProperty("file.separator");
    public static String path;
    public static GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    public static int screenWidth;
    public static int screenHeight;
    public static String pathDeviceFileOnClick;
    public static String ParentpathDeviceFileOnClick;
    public DefaultListModel listmodel;
    public static int adbViewState = 2;
    public static int AutoClick = 0;
    public ADBView(SingleFrameApplication app) throws Exception {
        super(app);
        initComponents();
//        jLabelToLeft.setVisible(false);
//        jLabelToRight.setVisible(false);
//        jLabelInstallAPK.setVisible(false);
//        jLabelScreenShot.setVisible(false);
//        jLabelOSK.setVisible(false);
//        jLabelListApps.setVisible(false);
        jLabelRunApp.setVisible(false);
        jLabelCloseApp.setVisible(false);
        jLabelUninstall.setVisible(false);
        jLabelClearData.setVisible(false);
        start();
        BufferedImage image = ImageIO.read(frame.getClass().getResource("/adb/resources/icon.png"));
        path = System.getProperty("user.home") + separator;
        screenWidth= gd.getDisplayMode().getWidth();
        screenHeight= gd.getDisplayMode().getHeight();
        frame.setIconImage(image);
        frame.addWindowListener(new WindowListener() {

            public void windowOpened(WindowEvent e) {

            }

            public void windowClosing(WindowEvent e) {
                    exit();
            }

            public void windowClosed(WindowEvent e) {
                
            }

            public void windowIconified(WindowEvent e) {
                minimize();  
                VisibleFrame visibleFrame = new VisibleFrame();
                visibleFrame.execute();
            }

            public void windowDeiconified(WindowEvent e) {
                
            }

            public void windowActivated(WindowEvent e) {
                
                frame.setState(frame.NORMAL);
            }

            public void windowDeactivated(WindowEvent e) {
                
            }
        });
        frame.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                point.x = e.getX();
                point.y = e.getY();
            }
        });
        frame.addMouseMotionListener(new MouseMotionAdapter() {

            @Override
            public void mouseDragged(MouseEvent e) {
                Point p = frame.getLocation();
                frame.setLocation(p.x + e.getX() - point.x,
                        p.y + e.getY() - point.y);
            }
        });
//        frame.setUndecorated(true);
        
        DefaultCaret caret = (DefaultCaret)jTextAreaStatus.getCaret();
        caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

//        frame.setResizable(false);
        //frame.toFront();
        //frame.setAlwaysOnTop(true);
        //frame.setLocation(610, 600);
        //frame.setLayout(new FlowLayout());
        //frame.setSize(new java.awt.Dimension(650, 600));
        //frame.setPreferredSize(new java.awt.Dimension(650, 600));
        if(osname.contains("Windows")){
        LoadingWindows Lw = new LoadingWindows();
        Lw.execute();
        }
        else {
        LoadingUbuntu Lu = new LoadingUbuntu();
        Lu.execute();
        }
        LoadingInBackground statusInfo = new LoadingInBackground();
        statusInfo.execute();
        
        loadTreeFileDevice b = new loadTreeFileDevice();
        b.execute();
        if(loadTreeFileDeviceSuccessStatus==0){
        output=output+"Check connection if cannot load file from Device.\n";
        jTextAreaStatus.setText(output);
        }

        jTextFieldCommand.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                
                command = jTextFieldCommand.getText();
                if(command.contains("adb")&&osname.contains("Windows")){
                 command=adbVariable + command;
                 runCommand run = new runCommand();
                    run.execute();
                }else
                {
                    runCommand run = new runCommand();
                    run.execute();
                }
                if("1".equals(command)){
                    output=output+"Extracted\n";
                jTextAreaStatus.setText(output);
                extractADB ex = new extractADB();
                ex.execute();
                }
//                String out = runcommand(command);
//                output = output + "#" + command + "\n" + out;
//                jTextAreaStatus.setText(output);
                
                
                
//                if (command.indexOf("list") > 0) {
//                    String lineByline = "";
//                    DefaultListModel listmodel = new DefaultListModel();
//                    BufferedReader br = new BufferedReader(new StringReader(out));
//                    try {
//                        while ((lineByline = br.readLine()) != null) {
//                            lineByline = lineByline.substring(8);
//                            listmodel.addElement(lineByline);
//                        }
//                    } catch (IOException ex) {
//                        System.out.print(ex + "----ex4\n");
//                        output = output + ex + "\n";
//                        jTextAreaStatus.setText(output);
//                    }
//                    JList listApps2 = new JList(listmodel);
//                    jScrollPaneDevice.remove(jTreeDevice);
//                    jTreeDevice.setVisible(false);
//                    jScrollPaneDevice.setViewportView(listApps2);
//                }
            }
        });  

    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jPanelFileExplorer = new javax.swing.JPanel();
        jPanelSystem = new javax.swing.JPanel();
        jScrollPaneSystem = new javax.swing.JScrollPane();
        jTreeSystem = new javax.swing.JTree();
        jComboBoxSystemDrive = new javax.swing.JComboBox();
        jPanelTransfer = new javax.swing.JPanel();
        jLabelToLeft = new javax.swing.JLabel();
        jLabelToRight = new javax.swing.JLabel();
        jLabelInstallAPK = new javax.swing.JLabel();
        jLabelCheckManifest = new javax.swing.JLabel();
        jLabelListApps = new javax.swing.JLabel();
        jLabelUninstall = new javax.swing.JLabel();
        jLabelRunApp = new javax.swing.JLabel();
        jLabelCloseApp = new javax.swing.JLabel();
        jLabelScreenShot = new javax.swing.JLabel();
        jLabelOSK = new javax.swing.JLabel();
        jLabelCheckDeviceConnect = new javax.swing.JLabel();
        jLabelClearData = new javax.swing.JLabel();
        jPanelDevice = new javax.swing.JPanel();
        jTextFieldFilter = new javax.swing.JTextField();
        jScrollPaneDevice = new javax.swing.JScrollPane();
        jTreeDevice = new javax.swing.JTree();
        jPanelStatus = new javax.swing.JPanel();
        jScrollPaneStatusLog = new javax.swing.JScrollPane();
        jTextAreaStatus = new javax.swing.JTextArea();
        jTextFieldCommand = new javax.swing.JTextField();
        jPanelDecorated = new javax.swing.JPanel();
        jLabelZoom = new javax.swing.JLabel();
        jPanelDevicesStatus = new javax.swing.JPanel();
        jLabelBattery = new javax.swing.JLabel();
        jLabelBatteryValue = new javax.swing.JLabel();
        jLabelSignal = new javax.swing.JLabel();
        jLabelSignalValue = new javax.swing.JLabel();
        jLabelCPU = new javax.swing.JLabel();
        jLabelCPUValue = new javax.swing.JLabel();
        jLabelRAM = new javax.swing.JLabel();
        jLabelRAMvalue = new javax.swing.JLabel();
        jLabelTemp = new javax.swing.JLabel();
        jLabelTempValue = new javax.swing.JLabel();
        jProgressBarDoInBackground = new javax.swing.JProgressBar();
        jLabelSdcard0 = new javax.swing.JLabel();
        jLabelSdcard0Value = new javax.swing.JLabel();
        jLabelSdcard1 = new javax.swing.JLabel();
        jLabelSdcard1Value = new javax.swing.JLabel();
        jCheckBoxAutoClick = new javax.swing.JCheckBox();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N

        jPanelFileExplorer.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelFileExplorer.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        jPanelFileExplorer.setPreferredSize(new java.awt.Dimension(450, 450));

        jPanelSystem.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelSystem.setBorder(javax.swing.BorderFactory.createEmptyBorder(-1, -1, -1, -1));
        jPanelSystem.setName("jPanelSystem"); // NOI18N
        jPanelSystem.setPreferredSize(new java.awt.Dimension(200, 400));

        jScrollPaneSystem.setName("jScrollPaneSystem"); // NOI18N

        jTreeSystem.setName("jTreeSystem"); // NOI18N
        jScrollPaneSystem.setViewportView(jTreeSystem);

        jComboBoxSystemDrive.setName("jComboBoxSystemDrive"); // NOI18N

        javax.swing.GroupLayout jPanelSystemLayout = new javax.swing.GroupLayout(jPanelSystem);
        jPanelSystem.setLayout(jPanelSystemLayout);
        jPanelSystemLayout.setHorizontalGroup(
            jPanelSystemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneSystem)
            .addComponent(jComboBoxSystemDrive, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanelSystemLayout.setVerticalGroup(
            jPanelSystemLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelSystemLayout.createSequentialGroup()
                .addComponent(jComboBoxSystemDrive, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPaneSystem))
        );

        jPanelTransfer.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelTransfer.setName("jPanelTransfer"); // NOI18N
        jPanelTransfer.setPreferredSize(new java.awt.Dimension(55, 400));

        jLabelToLeft.setIcon(resourceMap.getIcon("jLabelToLeft.icon")); // NOI18N
        jLabelToLeft.setName("jLabelToLeft"); // NOI18N
        jLabelToLeft.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelToLeftMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelToLeftMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelToLeftMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelToLeftMouseExited(evt);
            }
        });

        jLabelToRight.setIcon(resourceMap.getIcon("jLabelToRight.icon")); // NOI18N
        jLabelToRight.setName("jLabelToRight"); // NOI18N
        jLabelToRight.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelToRightMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelToRightMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelToRightMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelToRightMouseExited(evt);
            }
        });

        jLabelInstallAPK.setIcon(resourceMap.getIcon("jLabelInstallAPK.icon")); // NOI18N
        jLabelInstallAPK.setName("jLabelInstallAPK"); // NOI18N
        jLabelInstallAPK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelInstallAPKMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelInstallAPKMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelInstallAPKMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelInstallAPKMouseExited(evt);
            }
        });

        jLabelCheckManifest.setIcon(resourceMap.getIcon("jLabelCheckManifest.icon")); // NOI18N
        jLabelCheckManifest.setName("jLabelCheckManifest"); // NOI18N
        jLabelCheckManifest.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelCheckManifestMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelCheckManifestMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelCheckManifestMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelCheckManifestMouseExited(evt);
            }
        });

        jLabelListApps.setIcon(resourceMap.getIcon("jLabelListApps.icon")); // NOI18N
        jLabelListApps.setName("jLabelListApps"); // NOI18N
        jLabelListApps.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelListAppsMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelListAppsMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelListAppsMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelListAppsMouseExited(evt);
            }
        });

        jLabelUninstall.setIcon(resourceMap.getIcon("jLabelUninstall.icon")); // NOI18N
        jLabelUninstall.setName("jLabelUninstall"); // NOI18N
        jLabelUninstall.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelUninstallMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelUninstallMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelUninstallMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelListAppsMouseExited(evt);
            }
        });

        jLabelRunApp.setIcon(resourceMap.getIcon("jLabelRunApp.icon")); // NOI18N
        jLabelRunApp.setName("jLabelRunApp"); // NOI18N
        jLabelRunApp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelRunAppMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelRunAppMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelRunAppMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelRunAppMouseExited(evt);
            }
        });

        jLabelCloseApp.setIcon(resourceMap.getIcon("jLabelCloseApp.icon")); // NOI18N
        jLabelCloseApp.setName("jLabelCloseApp"); // NOI18N
        jLabelCloseApp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelCloseAppMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelCloseAppMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelCloseAppMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelCloseAppMouseExited(evt);
            }
        });

        jLabelScreenShot.setIcon(resourceMap.getIcon("jLabelScreenShot.icon")); // NOI18N
        jLabelScreenShot.setName("jLabelScreenShot"); // NOI18N
        jLabelScreenShot.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelScreenShotMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelScreenShotMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelScreenShotMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelScreenShotMouseExited(evt);
            }
        });

        jLabelOSK.setIcon(resourceMap.getIcon("jLabelOSK.icon")); // NOI18N
        jLabelOSK.setName("jLabelOSK"); // NOI18N
        jLabelOSK.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelOSKMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelOSKMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelOSKMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelOSKMouseExited(evt);
            }
        });

        jLabelCheckDeviceConnect.setIcon(resourceMap.getIcon("jLabelCheckDeviceConnect.icon")); // NOI18N
        jLabelCheckDeviceConnect.setName("jLabelCheckDeviceConnect"); // NOI18N
        jLabelCheckDeviceConnect.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelCheckDeviceConnectMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelCheckDeviceConnectMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelCheckDeviceConnectMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelCheckDeviceConnectMouseExited(evt);
            }
        });

        jLabelClearData.setIcon(resourceMap.getIcon("jLabelClearData.icon")); // NOI18N
        jLabelClearData.setName("jLabelClearData"); // NOI18N
        jLabelClearData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelClearDataMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelClearDataMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelClearDataMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelClearDataMouseExited(evt);
            }
        });

        javax.swing.GroupLayout jPanelTransferLayout = new javax.swing.GroupLayout(jPanelTransfer);
        jPanelTransfer.setLayout(jPanelTransferLayout);
        jPanelTransferLayout.setHorizontalGroup(
            jPanelTransferLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabelToLeft, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelToRight, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelInstallAPK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelCheckManifest, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelCloseApp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelRunApp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelUninstall, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelListApps, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelCheckDeviceConnect, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelOSK, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelScreenShot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabelClearData, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanelTransferLayout.setVerticalGroup(
            jPanelTransferLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTransferLayout.createSequentialGroup()
                .addComponent(jLabelToLeft)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelToRight)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelInstallAPK)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelCheckManifest)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelScreenShot)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelOSK, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelCheckDeviceConnect, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelListApps)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelUninstall)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelRunApp)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelCloseApp)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelClearData)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanelDevice.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelDevice.setBorder(javax.swing.BorderFactory.createEmptyBorder(-1, -1, -1, -1));
        jPanelDevice.setName("jPanelDevice"); // NOI18N
        jPanelDevice.setPreferredSize(new java.awt.Dimension(200, 400));

        jTextFieldFilter.setEnabled(false);
        jTextFieldFilter.setName("jTextFieldFilter"); // NOI18N
        jTextFieldFilter.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextFieldFilterKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextFieldFilterKeyTyped(evt);
            }
        });

        jScrollPaneDevice.setName("jScrollPaneDevice"); // NOI18N

        javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root");
        javax.swing.tree.DefaultMutableTreeNode treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Check connection");
        treeNode1.add(treeNode2);
        treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Check Driver");
        treeNode1.add(treeNode2);
        treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Click button Check");
        treeNode1.add(treeNode2);
        treeNode2 = new javax.swing.tree.DefaultMutableTreeNode("Exit and try again");
        treeNode1.add(treeNode2);
        jTreeDevice.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
        jTreeDevice.setName("jTreeDevice"); // NOI18N
        jScrollPaneDevice.setViewportView(jTreeDevice);

        javax.swing.GroupLayout jPanelDeviceLayout = new javax.swing.GroupLayout(jPanelDevice);
        jPanelDevice.setLayout(jPanelDeviceLayout);
        jPanelDeviceLayout.setHorizontalGroup(
            jPanelDeviceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPaneDevice)
            .addComponent(jTextFieldFilter)
        );
        jPanelDeviceLayout.setVerticalGroup(
            jPanelDeviceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelDeviceLayout.createSequentialGroup()
                .addComponent(jTextFieldFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPaneDevice))
        );

        javax.swing.GroupLayout jPanelFileExplorerLayout = new javax.swing.GroupLayout(jPanelFileExplorer);
        jPanelFileExplorer.setLayout(jPanelFileExplorerLayout);
        jPanelFileExplorerLayout.setHorizontalGroup(
            jPanelFileExplorerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFileExplorerLayout.createSequentialGroup()
                .addComponent(jPanelSystem, javax.swing.GroupLayout.DEFAULT_SIZE, 190, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelTransfer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelDevice, javax.swing.GroupLayout.DEFAULT_SIZE, 207, Short.MAX_VALUE))
        );
        jPanelFileExplorerLayout.setVerticalGroup(
            jPanelFileExplorerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelSystem, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE)
            .addComponent(jPanelTransfer, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE)
            .addComponent(jPanelDevice, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE)
        );

        jPanelStatus.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelStatus.setBorder(javax.swing.BorderFactory.createEmptyBorder(-1, -1, -1, -1));

        jTextAreaStatus.setBackground(resourceMap.getColor("jTextAreaStatus.background")); // NOI18N
        jTextAreaStatus.setForeground(resourceMap.getColor("jTextAreaStatus.foreground")); // NOI18N
        jTextAreaStatus.setLineWrap(true);
        jTextAreaStatus.setWrapStyleWord(true);
        jScrollPaneStatusLog.setViewportView(jTextAreaStatus);

        jTextFieldCommand.setName("jTextFieldCommand"); // NOI18N

        javax.swing.GroupLayout jPanelStatusLayout = new javax.swing.GroupLayout(jPanelStatus);
        jPanelStatus.setLayout(jPanelStatusLayout);
        jPanelStatusLayout.setHorizontalGroup(
            jPanelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTextFieldCommand)
            .addComponent(jScrollPaneStatusLog)
        );
        jPanelStatusLayout.setVerticalGroup(
            jPanelStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelStatusLayout.createSequentialGroup()
                .addComponent(jTextFieldCommand, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPaneStatusLog, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanelDecorated.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelDecorated.setBorder(javax.swing.BorderFactory.createEmptyBorder(-1, -1, -1, -1));
        jPanelDecorated.setName("jPanelDecorated"); // NOI18N
        jPanelDecorated.setPreferredSize(new java.awt.Dimension(470, 49));

        jLabelZoom.setIcon(resourceMap.getIcon("jLabelZoom.icon")); // NOI18N
        jLabelZoom.setName("jLabelZoom"); // NOI18N
        jLabelZoom.setRequestFocusEnabled(false);
        jLabelZoom.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelZoomMouseClicked(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jLabelZoomMouseExited(evt);
            }
            public void mousePressed(java.awt.event.MouseEvent evt) {
                jLabelZoomMousePressed(evt);
            }
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabelZoomMouseExited(evt);
            }
        });

        jPanelDevicesStatus.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        jPanelDevicesStatus.setName("jPanelDevicesStatus"); // NOI18N
        jPanelDevicesStatus.setPreferredSize(new java.awt.Dimension(0, 96));

        jLabelBattery.setIcon(resourceMap.getIcon("jLabelBattery.icon")); // NOI18N
        jLabelBattery.setName("jLabelBattery"); // NOI18N
        jLabelBattery.setPreferredSize(new java.awt.Dimension(50, 12));

        jLabelBatteryValue.setName("jLabelBatteryValue"); // NOI18N
        jLabelBatteryValue.setPreferredSize(new java.awt.Dimension(25, 12));

        jLabelSignal.setIcon(resourceMap.getIcon("jLabelSignal.icon")); // NOI18N
        jLabelSignal.setName("jLabelSignal"); // NOI18N
        jLabelSignal.setPreferredSize(new java.awt.Dimension(50, 12));

        jLabelSignalValue.setName("jLabelSignalValue"); // NOI18N
        jLabelSignalValue.setPreferredSize(new java.awt.Dimension(25, 12));

        jLabelCPU.setIcon(resourceMap.getIcon("jLabelCPU.icon")); // NOI18N
        jLabelCPU.setName("jLabelCPU"); // NOI18N
        jLabelCPU.setPreferredSize(new java.awt.Dimension(40, 12));

        jLabelCPUValue.setName("jLabelCPUValue"); // NOI18N
        jLabelCPUValue.setPreferredSize(new java.awt.Dimension(40, 12));

        jLabelRAM.setText(resourceMap.getString("jLabelRAM.text")); // NOI18N
        jLabelRAM.setName("jLabelRAM"); // NOI18N
        jLabelRAM.setPreferredSize(new java.awt.Dimension(40, 12));

        jLabelRAMvalue.setName("jLabelRAMvalue"); // NOI18N
        jLabelRAMvalue.setPreferredSize(new java.awt.Dimension(40, 12));

        jLabelTemp.setIcon(resourceMap.getIcon("jLabelTemp.icon")); // NOI18N
        jLabelTemp.setName("jLabelTemp"); // NOI18N
        jLabelTemp.setPreferredSize(new java.awt.Dimension(40, 12));

        jLabelTempValue.setName("jLabelTempValue"); // NOI18N
        jLabelTempValue.setPreferredSize(new java.awt.Dimension(40, 12));

        jProgressBarDoInBackground.setName("jProgressBarDoInBackground"); // NOI18N

        jLabelSdcard0.setText(resourceMap.getString("jLabelSdcard0.text")); // NOI18N
        jLabelSdcard0.setName("jLabelSdcard0"); // NOI18N
        jLabelSdcard0.setPreferredSize(new java.awt.Dimension(25, 12));

        jLabelSdcard0Value.setName("jLabelSdcard0Value"); // NOI18N
        jLabelSdcard0Value.setPreferredSize(new java.awt.Dimension(45, 12));

        jLabelSdcard1.setText(resourceMap.getString("jLabelSdcard1.text")); // NOI18N
        jLabelSdcard1.setName("jLabelSdcard1"); // NOI18N
        jLabelSdcard1.setPreferredSize(new java.awt.Dimension(25, 12));

        jLabelSdcard1Value.setName("jLabelSdcard1Value"); // NOI18N
        jLabelSdcard1Value.setPreferredSize(new java.awt.Dimension(45, 12));

        javax.swing.GroupLayout jPanelDevicesStatusLayout = new javax.swing.GroupLayout(jPanelDevicesStatus);
        jPanelDevicesStatus.setLayout(jPanelDevicesStatusLayout);
        jPanelDevicesStatusLayout.setHorizontalGroup(
            jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDevicesStatusLayout.createSequentialGroup()
                .addComponent(jLabelBattery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelBatteryValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelCPU, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelCPUValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelSdcard0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabelSdcard0Value, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
            .addGroup(jPanelDevicesStatusLayout.createSequentialGroup()
                .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanelDevicesStatusLayout.createSequentialGroup()
                        .addComponent(jLabelSignal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelSignalValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelTemp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jProgressBarDoInBackground, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelDevicesStatusLayout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jLabelRAM, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelRAMvalue, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanelDevicesStatusLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelTempValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelSdcard1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelSdcard1Value, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        jPanelDevicesStatusLayout.setVerticalGroup(
            jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDevicesStatusLayout.createSequentialGroup()
                .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelSdcard0Value, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelBattery, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelBatteryValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelCPU, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelCPUValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelSdcard0, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelTempValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelSdcard1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelSdcard1Value, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelTemp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelSignal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelSignalValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jProgressBarDoInBackground, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanelDevicesStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabelRAM, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelRAMvalue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jCheckBoxAutoClick.setText(resourceMap.getString("jCheckBoxAutoClick.text")); // NOI18N
        jCheckBoxAutoClick.setName("jCheckBoxAutoClick"); // NOI18N
        jCheckBoxAutoClick.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jCheckBoxAutoClickStateChanged(evt);
            }
        });
        jCheckBoxAutoClick.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxAutoClickActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelDecoratedLayout = new javax.swing.GroupLayout(jPanelDecorated);
        jPanelDecorated.setLayout(jPanelDecoratedLayout);
        jPanelDecoratedLayout.setHorizontalGroup(
            jPanelDecoratedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelDecoratedLayout.createSequentialGroup()
                .addComponent(jLabelZoom)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelDevicesStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 302, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxAutoClick)
                .addContainerGap())
        );
        jPanelDecoratedLayout.setVerticalGroup(
            jPanelDecoratedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabelZoom, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(jPanelDecoratedLayout.createSequentialGroup()
                .addGroup(jPanelDecoratedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelDevicesStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jCheckBoxAutoClick))
                .addGap(0, 2, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFileExplorer, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)
            .addComponent(jPanelStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanelDecorated, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addComponent(jPanelFileExplorer, javax.swing.GroupLayout.DEFAULT_SIZE, 457, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanelDecorated, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        setComponent(mainPanel);
    }// </editor-fold>//GEN-END:initComponents
    private void jLabelToLeftMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelToLeftMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelToLeft.setIcon(resourceMap.getIcon("jLabelToLeft.icon2"));
    }//GEN-LAST:event_jLabelToLeftMousePressed
    private void jLabelToLeftMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelToLeftMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelToLeft.setIcon(resourceMap.getIcon("jLabelToLeft.icon"));
    }//GEN-LAST:event_jLabelToLeftMouseExited
    private void jLabelInstallAPKMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelInstallAPKMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelInstallAPK.setIcon(resourceMap.getIcon("jLabelInstallAPK.icon2"));
    }//GEN-LAST:event_jLabelInstallAPKMousePressed
    private void jLabelInstallAPKMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelInstallAPKMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelInstallAPK.setIcon(resourceMap.getIcon("jLabelInstallAPK.icon"));
    }//GEN-LAST:event_jLabelInstallAPKMouseExited
    private void jLabelInstallAPKMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelInstallAPKMouseClicked
        //Setcursor(1);
//        String out = runcommand(adb + " install -r " + pathPCfile);
//        output = output + "#adb install -r " + pathPCfile + "\n";
//        output = output + out;
        command = adbVariable + " install " + pathPCfile;
        output=output+"#adb install "+pathPCfile+"\nInstalling...\n";
        jTextAreaStatus.setText(output);
        runCommand run = new runCommand();
        run.execute();
        //jTextAreaStatus.setText(output);
        //Setcursor(0);
    }//GEN-LAST:event_jLabelInstallAPKMouseClicked
    private void jLabelToRightMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelToRightMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelToRight.setIcon(resourceMap.getIcon("jLabelToRight.icon2"));
    }//GEN-LAST:event_jLabelToRightMousePressed
    private void jLabelToRightMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelToRightMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelToRight.setIcon(resourceMap.getIcon("jLabelToRight.icon"));
    }//GEN-LAST:event_jLabelToRightMouseExited
    private void jLabelCheckManifestMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCheckManifestMouseClicked
        String CheckManifestcommand = aaptVariable + " dump badging " + pathPCfile;
        output = output + "#" + CheckManifestcommand + "\n";
        jTextAreaStatus.setText(output);
        JTextArea textArea = new JTextArea();
        JScrollPane scrollPane = new JScrollPane(textArea);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setText(runcommand(CheckManifestcommand));
        scrollPane.setPreferredSize(new Dimension(700, 700));
        JOptionPane op = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE);
        JDialog dialog = op.createDialog("#" + CheckManifestcommand);
        dialog.setAlwaysOnTop(false); //<-- this line
        dialog.setVisible(true);
        

    }//GEN-LAST:event_jLabelCheckManifestMouseClicked
    private void jLabelCheckManifestMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCheckManifestMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelCheckManifest.setIcon(resourceMap.getIcon("jLabelCheckManifest.icon2"));
    }//GEN-LAST:event_jLabelCheckManifestMousePressed
    private void jLabelCheckManifestMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCheckManifestMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelCheckManifest.setIcon(resourceMap.getIcon("jLabelCheckManifest.icon"));
    }//GEN-LAST:event_jLabelCheckManifestMouseExited
    private void jLabelListAppsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelListAppsMouseClicked
        String listpackages = adbVariable + " shell pm list packages";
        output = output + "#adb shell pm list packages\n";
        String list = runcommand(listpackages);
        jTextAreaStatus.setText(output);
        if(list.length()>150){
        //System.out.print(list);
        String lineByline = "";
        listmodel = new DefaultListModel();
        BufferedReader br = new BufferedReader(new StringReader(list));
        try {
            while ((lineByline = br.readLine()) != null) {
                lineByline = lineByline.substring(8);
                listmodel.addElement(lineByline);
            }
        } catch (IOException ex) {
            System.out.print(ex + "----ex14\n");
            output = output + ex + "----ex14\n";
            jTextAreaStatus.setText(output);
        }
        jTextFieldFilter.setEnabled(true);
        listApps = new JList(listmodel);
        listApps.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        listApps.setEnabled(true);
        listApps.setVisible(true);
        listApps.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                
                if (e.getClickCount() == 2) {
                    //System.out.print("e.getClickCount() == 2\n");
                    if (listApps.getSelectedValue() != null) {
                        //System.out.print("listApps.getSelectedValue()="+listApps.getSelectedValue());
                        String CheckManifestcommand = adbVariable + " shell dumpsys package " + listApps.getSelectedValue()+"\n";
                        //System.out.print("CheckManifestcommand="+CheckManifestcommand+"\n");
                        JTextArea textArea = new JTextArea();
                        JScrollPane scrollPane = new JScrollPane(textArea);
                        textArea.setLineWrap(true);
                        textArea.setWrapStyleWord(true);
                        textArea.setText(runcommand(CheckManifestcommand));
                        scrollPane.setPreferredSize(new Dimension(700, 700));
                        JOptionPane op = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE);
                        JDialog dialog = op.createDialog("#" + CheckManifestcommand);
                        dialog.setAlwaysOnTop(false); //<-- this line
                        dialog.setVisible(true);
                    }
                }
            }
        });
        jScrollPaneDevice.remove(jTreeDevice);
        listApps.setEnabled(true);
        listApps.setVisible(true);
        jTreeDevice.setVisible(false);
        jTreeDevice.setEnabled(false);
        jScrollPaneDevice.add(listApps);
        jScrollPaneDevice.setViewportView(listApps);
        jLabelRunApp.setVisible(true);
        jLabelCloseApp.setVisible(true);
        jLabelUninstall.setVisible(true);
        jLabelClearData.setVisible(true);
        }else {
        output = output + "Check connection.\n";
        jTextAreaStatus.setText(output);
        }
    }//GEN-LAST:event_jLabelListAppsMouseClicked
    private void jLabelListAppsMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelListAppsMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelListApps.setIcon(resourceMap.getIcon("jLabelListApps.icon2"));
    }//GEN-LAST:event_jLabelListAppsMousePressed
    private void jLabelListAppsMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelListAppsMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelListApps.setIcon(resourceMap.getIcon("jLabelListApps.icon"));
    }//GEN-LAST:event_jLabelListAppsMouseExited
    private void jLabelUninstallMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelUninstallMouseClicked
        if (listApps.getSelectedValue() != null) {
            command = adbVariable + " uninstall " + listApps.getSelectedValue().toString();
            output = output + "#adb uninstall " + listApps.getSelectedValue().toString()+"\n";
            jTextAreaStatus.setText(output);
            runCommand run = new runCommand();
            run.execute();
            
        } else {
            output = output + "No App selected.\n";
            jTextAreaStatus.setText(output);
        }
        
        
    }//GEN-LAST:event_jLabelUninstallMouseClicked
    private void jLabelUninstallMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelUninstallMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelUninstall.setIcon(resourceMap.getIcon("jLabelUninstall.icon2"));
    }//GEN-LAST:event_jLabelUninstallMousePressed
    private void jLabelUninstallMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelUninstallMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelUninstall.setIcon(resourceMap.getIcon("jLabelUninstall.icon"));
    }//GEN-LAST:event_jLabelUninstallMouseExited
    private void jLabelRunAppMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelRunAppMouseClicked
        if(listApps.getSelectedValue()!=null){
//        String AppInfos =runcommand(adbVariable + " shell dumpsys package " + listApps.getSelectedValue());
//        BufferedReader br = new BufferedReader(new StringReader(AppInfos));
//        String lineByline="";
//        String avtivity="";
//        try {
//                    while ((lineByline = br.readLine()) != null) {
//                        if (lineByline.contains("android.intent.action.MAIN")) {
//                            avtivity = br.readLine();
//                        }
//                    }
//                } catch (IOException ex) {
//                    System.out.print(ex + "----ex22\n");
//                    output = output + ex + "\n";
//                    jTextAreaStatus.setText(output);
//                }
//        if(avtivity.length()>0){
//            int indexFilter = avtivity.indexOf("filter");
//            avtivity=avtivity.substring(17, indexFilter-2);
            String runApp =runcommand(adbVariable+" shell monkey -p "+listApps.getSelectedValue().toString()+" 1");
            output = output +adbVariable+" shell monkey -p "+listApps.getSelectedValue().toString()+" 1\n"+runApp+"\n";
            jTextAreaStatus.setText(output);
//        }else{
//            output = output + "Cannot run this app.\n";
//             jTextAreaStatus.setText(output);
//        }
        
        //System.out.print("avtivity="+avtivity+".");
        }
        else {
        output = output + "Select an App.\n";
             jTextAreaStatus.setText(output);
        }
        
    }//GEN-LAST:event_jLabelRunAppMouseClicked
    private void jLabelRunAppMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelRunAppMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelRunApp.setIcon(resourceMap.getIcon("jLabelRunApp.icon2"));
    }//GEN-LAST:event_jLabelRunAppMousePressed
    private void jLabelRunAppMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelRunAppMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelRunApp.setIcon(resourceMap.getIcon("jLabelRunApp.icon"));
    }//GEN-LAST:event_jLabelRunAppMouseExited
    private void jLabelCloseAppMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCloseAppMouseClicked
            if(listApps.getSelectedValue()!=null){
            String CloseApp =runcommand(adbVariable+" shell am force-stop "+listApps.getSelectedValue().toString());
            output = output +adbVariable+" shell am force-stop "+listApps.getSelectedValue().toString()+"\n"+CloseApp+"\n";
            jTextAreaStatus.setText(output);
            }else {
            output = output +"Select an app to Close.\n";
            jTextAreaStatus.setText(output);
            }
            
    }//GEN-LAST:event_jLabelCloseAppMouseClicked
    private void jLabelCloseAppMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCloseAppMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelCloseApp.setIcon(resourceMap.getIcon("jLabelCloseApp.icon2"));
    }//GEN-LAST:event_jLabelCloseAppMousePressed
    private void jLabelCloseAppMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCloseAppMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelCloseApp.setIcon(resourceMap.getIcon("jLabelCloseApp.icon"));
    }//GEN-LAST:event_jLabelCloseAppMouseExited
    private void jLabelScreenShotMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelScreenShotMouseClicked
        screenShot ss = new screenShot();
        if (screenShotSuccessStatus == 0) {
            output = output + "Check connection if cannot load Screen Shot.\n";
            jTextAreaStatus.setText(output);
        }
        ss.execute();
                
    }//GEN-LAST:event_jLabelScreenShotMouseClicked
    private void jLabelScreenShotMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelScreenShotMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelScreenShot.setIcon(resourceMap.getIcon("jLabelScreenShot.icon2"));
    }//GEN-LAST:event_jLabelScreenShotMousePressed
    private void jLabelScreenShotMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelScreenShotMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelScreenShot.setIcon(resourceMap.getIcon("jLabelScreenShot.icon"));
    }//GEN-LAST:event_jLabelScreenShotMouseExited
    private void jLabelZoomMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelZoomMouseClicked
        //org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        if (zoom == 0) {
            //mainPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(resourceMap.getColor("mainPanel.border.highlightColor"), resourceMap.getColor("mainPanel.border.shadowColor")));
            //jPanelFileExplorer.setPreferredSize(new java.awt.Dimension(450, 400));
            frame.setSize(new java.awt.Dimension(480, 700));
            mainPanel.setSize(new java.awt.Dimension(480, 700));
            frame.setLocation((screenWidth - 450) / 2, 30);
            zoom = 1;
        } else if (zoom == 1) {
            //mainPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(resourceMap.getColor("mainPanel.border.highlightColor2"), resourceMap.getColor("mainPanel.border.shadowColor2")));
            //jPanelFileExplorer.setPreferredSize(new java.awt.Dimension(1000, 650));
            frame.setSize(new java.awt.Dimension(1000, screenHeight - 150));
            mainPanel.setSize(new java.awt.Dimension(1000, screenHeight - 150));
            frame.setLocation((screenWidth - 1000) / 2, 75);
            zoom = 0;
        }
    }//GEN-LAST:event_jLabelZoomMouseClicked
    private void jLabelZoomMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelZoomMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelZoom.setIcon(resourceMap.getIcon("jLabelZoom.icon2"));
    }//GEN-LAST:event_jLabelZoomMousePressed
    private void jLabelZoomMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelZoomMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelZoom.setIcon(resourceMap.getIcon("jLabelZoom.icon"));
    }//GEN-LAST:event_jLabelZoomMouseExited
    private void jLabelCheckDeviceConnectMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCheckDeviceConnectMouseClicked

        jTextFieldFilter.setEnabled(false);
        loadTreeFileDevice b = new loadTreeFileDevice();
        b.execute();
        jTreeDevice.setVisible(true);
        jScrollPaneDevice.setViewportView(jTreeDevice);
        String out = runcommand(adbVariable + " devices");
        output = output + "#adb devices" + "\n" + out;
        jTextAreaStatus.setText(output);
        jLabelRunApp.setVisible(false);
        jLabelCloseApp.setVisible(false);
        jLabelUninstall.setVisible(false);
        jLabelClearData.setVisible(false);
    }//GEN-LAST:event_jLabelCheckDeviceConnectMouseClicked
    private void jLabelCheckDeviceConnectMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCheckDeviceConnectMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelCheckDeviceConnect.setIcon(resourceMap.getIcon("jLabelCheckDeviceConnect.icon2"));
    }//GEN-LAST:event_jLabelCheckDeviceConnectMousePressed
    private void jLabelCheckDeviceConnectMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelCheckDeviceConnectMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelCheckDeviceConnect.setIcon(resourceMap.getIcon("jLabelCheckDeviceConnect.icon"));
    }//GEN-LAST:event_jLabelCheckDeviceConnectMouseExited
    private void jLabelOSKMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelOSKMouseClicked
        if(OSKopen==0){
        OSK osk = new OSK();
        osk.setVisible(true);
        frame.setState(JFrame.ICONIFIED);
        adbViewState=0;
        }
    }//GEN-LAST:event_jLabelOSKMouseClicked
    private void jLabelOSKMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelOSKMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelOSK.setIcon(resourceMap.getIcon("jLabelOSK.icon2"));
    }//GEN-LAST:event_jLabelOSKMousePressed
    private void jLabelOSKMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelOSKMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelOSK.setIcon(resourceMap.getIcon("jLabelOSK.icon"));
    }//GEN-LAST:event_jLabelOSKMouseExited
    private void jLabelToLeftMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelToLeftMouseClicked
        if (evt.getButton() == MouseEvent.BUTTON1) {
        String resourcePath = "";
        //COPY FROM APPLICATION TO pc
        if (listApps.isVisible()) {
            //System.out.print("listApps.isVisible()=true");
            if (listApps.getSelectedValue() != null) {
                String packageInfoCommand = adbVariable + " shell dumpsys package " + listApps.getSelectedValue();
                String packageInfo = runcommand(packageInfoCommand);

                String lineByline = "";
                BufferedReader br = new BufferedReader(new StringReader(packageInfo));
                try {
                    while ((lineByline = br.readLine()) != null) {
                        if (lineByline.contains("resourcePath")) {
                            resourcePath = lineByline;
                        }
                    }
                } catch (IOException ex) {
                    System.out.print(ex + "----ex22\n");
                    output = output + ex + "\n";
                    jTextAreaStatus.setText(output);
                }
                int index = resourcePath.indexOf("resourcePath=");
                if (resourcePath.length() > 14) {
                    resourcePath = resourcePath.substring(index + 13);
                }
                if (getSystemDirectoryOnSelect().length() > 1) {
                    command = adbVariable + " pull " + resourcePath + " " + getSystemDirectoryOnSelect();
                    output = output + command + "\nDownloading...\n";
                    jTextAreaStatus.setText(output);
                    runCommand run = new runCommand();
                    run.execute();
                    output = output + command + "\nFinish...\n";
                    jTextAreaStatus.setText(output);
                } else {
                    output = output + "Select Folder copy to.\n";
                    jTextAreaStatus.setText(output);
                }
            } else {
                output = output + "Select an application\n";
                jTextAreaStatus.setText(output);
            }

        }
        
        //COPY FROM Jtree TO PC
        if (jTreeDevice.isVisible()) {
            if (getSystemDirectoryOnSelect().length() > 1) {
                    if(pathDeviceFileOnClick!=null){

                        command = adbVariable + " pull " + pathDeviceFileOnClick + " " + getSystemDirectoryOnSelect();
                        output = output + command + "\nDownloading...\n";
                        jTextAreaStatus.setText(output);
                        runCommand run = new runCommand();
                        run.execute();
                        output = output + command + "\nFinish...\n";
                    jTextAreaStatus.setText(output);
                    }else{
                        output = output + "Select a file\n";
                        jTextAreaStatus.setText(output);
                    }
            } else {
                output = output + "Select Folder copy to.\n";
                jTextAreaStatus.setText(output);
            }
        }
        
        }
        
        if (evt.getButton() == MouseEvent.BUTTON3) {
            
            String resourcePath = "";
        //COPY FROM APPLICATION TO pc
        if (listApps.isVisible()) {
            //System.out.print("listApps.isVisible()=true");
            if (listApps.getSelectedValue() != null) {
                String packageInfoCommand = adbVariable + " shell dumpsys package " + listApps.getSelectedValue();
                String packageInfo = runcommand(packageInfoCommand);

                String lineByline = "";
                BufferedReader br = new BufferedReader(new StringReader(packageInfo));
                try {
                    while ((lineByline = br.readLine()) != null) {
                        if (lineByline.contains("resourcePath")) {
                            resourcePath = lineByline;
                        }
                    }
                } catch (IOException ex) {
                    System.out.print(ex + "----ex22\n");
                    output = output + ex + "\n";
                    jTextAreaStatus.setText(output);
                }
                int index = resourcePath.indexOf("resourcePath=");
                if (resourcePath.length() > 14) {
                    resourcePath = resourcePath.substring(index + 13);
                }
                
                    command = adbVariable + " pull " + resourcePath + " " + path+"Desktop";
                    output = output + command + "\nDownloading...\n";
                    jTextAreaStatus.setText(output);
                    runCommand run = new runCommand();
                    run.execute();
                    output = output + command + "\nFinish...\n";
                    jTextAreaStatus.setText(output);
                
            } else {
                output = output + "Select an application\n";
                jTextAreaStatus.setText(output);
            }

        }
        
        //COPY FROM Jtree TO PC
        if (jTreeDevice.isVisible()) {
          
                    if(pathDeviceFileOnClick!=null){

                        command = adbVariable + " pull " + pathDeviceFileOnClick + " "+path+"Desktop";
                        output = output + command + "\nDownloading...\n";
                        jTextAreaStatus.setText(output);
                        runCommand run = new runCommand();
                        run.execute();
                        output = output + command + "\nFinish...\n";
                    jTextAreaStatus.setText(output);
                    }else{
                        output = output + "Select a file\n";
                        jTextAreaStatus.setText(output);
                    }
           
        }
            
            
            
        }
        
        
    }//GEN-LAST:event_jLabelToLeftMouseClicked
    private void jLabelToRightMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelToRightMouseClicked
if (evt.getButton() == MouseEvent.BUTTON1) {
        if (listApps.isVisible()) {
            output=output+"Click CHECK button to show Directory of Device.\n";
            jTextAreaStatus.setText(output);
        }
        if (jTreeDevice.isVisible()) {
           if (getSystemFileOnSelect().length() > 0) {
               System.out.print("getSystemFileOnSelect().length() > 0");
               if(ParentpathDeviceFileOnClick.length()>0){
                   pathDeviceFileOnClick=removeFileinPathUbuntu(pathDeviceFileOnClick);
                    command = adbVariable + " push " + getSystemFileOnSelect() + " " + pathDeviceFileOnClick;
                    output = output + command + "\nUploading...\n";
                    jTextAreaStatus.setText(output);
                    runCommand run = new runCommand();
                    run.execute();
               }else{
                   output = output + "Select a file of Folder need copy to.\n";
                   jTextAreaStatus.setText(output);
               }
            } else {
                output = output + "Select a file.\n";
                jTextAreaStatus.setText(output);
            }
        }else{
        output=output+"Click CHECK button to show Directory of Device.\n";
        jTextAreaStatus.setText(output);
        }
}
if (evt.getButton() == MouseEvent.BUTTON3) {
 

                   
                    command = adbVariable + " push " + getSystemFileOnSelect() + " /storage/sdcard0/" ;
                    output = output + command + "\nUploading...\n";
                    jTextAreaStatus.setText(output);
                    runCommand run = new runCommand();
                    run.execute();    
}
    }//GEN-LAST:event_jLabelToRightMouseClicked
    private void jTextFieldFilterKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldFilterKeyTyped
        
    }//GEN-LAST:event_jTextFieldFilterKeyTyped
    private void jTextFieldFilterKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldFilterKeyReleased
            DefaultListModel listmodelFilter = new DefaultListModel();
            String filter = jTextFieldFilter.getText();
            if(filter.length()>0){
            int size = listmodel.getSize();
            int i=1;
            while(i<size){
                if(listmodel.elementAt(i).toString().contains(filter)==true){
                        listmodelFilter.addElement(listmodel.elementAt(i));
//                        System.out.print("\nlistmodel.elementAt(i)="+listmodel.elementAt(i));
                }
                i++;
            }
            listApps.setModel(listmodelFilter);
            }else
            {
            listApps.setModel(listmodel);
            }
            
    }//GEN-LAST:event_jTextFieldFilterKeyReleased
    private void jLabelClearDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelClearDataMouseClicked
        if(listApps.getSelectedValue().toString()!=null){
        command = adbVariable + " shell pm clear " + listApps.getSelectedValue().toString();
        output=output+"#adb shell pm clear "+listApps.getSelectedValue().toString()+"\n";
        jTextAreaStatus.setText(output);
        runCommand run = new runCommand();
        run.execute();
        }
        else {
            output = output + "No App selected.\n";
            jTextAreaStatus.setText(output);
        }
    }//GEN-LAST:event_jLabelClearDataMouseClicked
    private void jLabelClearDataMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelClearDataMouseExited
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelClearData.setIcon(resourceMap.getIcon("jLabelClearData.icon"));
    }//GEN-LAST:event_jLabelClearDataMouseExited
    private void jLabelClearDataMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelClearDataMousePressed
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelClearData.setIcon(resourceMap.getIcon("jLabelClearData.icon2"));
    }//GEN-LAST:event_jLabelClearDataMousePressed
    private void jLabelClearDataMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelClearDataMouseReleased
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        jLabelClearData.setIcon(resourceMap.getIcon("jLabelClearData.icon"));
    }//GEN-LAST:event_jLabelClearDataMouseReleased

    private void jCheckBoxAutoClickStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBoxAutoClickStateChanged

        
    }//GEN-LAST:event_jCheckBoxAutoClickStateChanged

    private void jCheckBoxAutoClickActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxAutoClickActionPerformed
        if(jCheckBoxAutoClick.isSelected()){
            AutoClick=1;
            AutoClick al = new AutoClick();
            al.execute();
        }
        else
        {
            AutoClick=0;
            AutoClick al = new AutoClick();
            al.execute();
        }
    }//GEN-LAST:event_jCheckBoxAutoClickActionPerformed
    public static void ChangeFocus() {
//        if (focus % 2 == 0) {
//            frame.setFocusableWindowState(true);
//            focus++;
//            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
////            jLabelLock.setIcon(resourceMap.getIcon("jButtonFocus.icon2")); // NOI18N
//            frame.setResizable(true);
//            frame.setAlwaysOnTop(false);
//
//        } else {
//            
//            frame.setFocusableWindowState(false);
//            focus++;
//            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
////            jLabelLock.setIcon(resourceMap.getIcon("jButtonFocus.icon")); // NOI18N
//            frame.setResizable(false);
//            frame.setAlwaysOnTop(true);
//
//        }
    }
    public void minimize() {
        if (tray % 2 == 1) {
//frame.setState(frame.ICONIFIED);
            frame.setVisible(false);
            tray = tray + 1;
        } else {
//frame.setState(frame.NORMAL);
            frame.setVisible(true);
            frame.setState(frame.NORMAL);
            tray = tray + 1;
        }
    }
    public void start() {
        if (SystemTray.isSupported()) {
            try {
                SystemTray sysTray = SystemTray.getSystemTray();
                MouseListener mouseListener = new MouseListener() {

                    public void mouseClicked(MouseEvent e) {
                        minimize();
                    }

                    public void mouseEntered(MouseEvent e) {
                        //System.out.println("Tray Icon - Mouse entered!");                 
                    }

                    public void mousePressed(MouseEvent e) {
                        //System.out.println("Tray Icon - Mouse pressed!");                 
                    }

                    public void mouseExited (MouseEvent e) {
                        //System.out.println("Tray Icon - Mouse released!");                 
                    }

                    public void mouseReleased(MouseEvent e) {
                        
                    }
                };
                BufferedImage image = ImageIO.read(frame.getClass().getResource("/adb/resources/icon.png"));
                //Image trayImage = Toolkit.getDefaultToolkit().getImage(IMAGE);
                createMenu();
                TrayIcon trayIcon = new TrayIcon(image, "adb", menu);
                //trayIcon.addActionListener(actionListener);
                trayIcon.addMouseListener(mouseListener);
                trayIcon.setImageAutoSize(true);
                try {
                    sysTray.add(trayIcon);
                    //trayIcon.displayMessage("caption", "howdy", TrayIcon.MessageType.INFO);
                } catch (AWTException ex) {
                    System.out.print(ex + "----ex13\n");
                    output = output + ex + "----ex13\n";
                    jTextAreaStatus.setText(output);
                }
            } catch (IOException ex) {
                System.out.print(ex + "----ex16\n");
                output = output + ex + "----ex16\n";
                jTextAreaStatus.setText(output);
            }
        } else {
            System.err.println("SystemTray not supported");
        }
    }
    public static void createMenu() {
        menu = new PopupMenu();
        MenuItem about = new MenuItem("By Tam Anh");

        MenuItem exit = new MenuItem("Exit");
        exit.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {
                //System.exit(0);
                exit();
            }
        });
        menu.add(about);
        menu.addSeparator();
        menu.add(exit);
    }
    public static void showPopup(String message, int w, int h) {
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(adb.ADBApp.class).getContext().getResourceMap(ADBView.class);
        Component component = null;
        JLabel JLabelPopup = new JLabel();
        JLabelPopup.setText("<html>" + message + "</html>");
        JLabelPopup.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        JLabelPopup.setBackground(Color.yellow);
        JLabelPopup.setFont(resourceMap.getFont("All.font"));
        JLabelPopup.setForeground(Color.RED);
        JLabelPopup.setPreferredSize(new java.awt.Dimension(w, h));
        PopupFactory factory = PopupFactory.getSharedInstance();
        int x = 850;
        int y = 20;
        final Popup popup = factory.getPopup(component, JLabelPopup, x, y);
        popup.show();
        ActionListener hider = new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                popup.hide();
            }
        };
        //if (message.equals("Gapro")) {popup.hide();        }
        Timer timer = new Timer(3000, hider);
        timer.start();
    }
    public static String[] getPCFileSystemRoots() {
        String[] systemInfo = null;
        return systemInfo = getLogicalDrivers();

    }
    public static void showPCTree() {
        jScrollPaneSystem.setViewportView(jTreeSystem);
        jComboBoxSystemDrive.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                String drive = jComboBoxSystemDrive.getSelectedItem().toString();
                jTreeSystem.setModel(new FileTreeModel(new File(drive)));
                //System.out.print(drive);
            }
        });
        DefaultComboBoxModel directory = new DefaultComboBoxModel(getPCFileSystemRoots());
        if (readSavedDirectory().length() > 1) {
            directory.addElement(readSavedDirectory());//add saved directory from file .adb
        }
        if(path.length()>1){
        directory.addElement(path);
        directory.addElement(path+"Desktop");
        directory.addElement(path+"Downloads");
        directory.addElement(path+"Documents");
        }
        String ADBJarPath = getJarpath();
        //System.out.print("getJarpath()\n");
        if (ADBJarPath.contains(".jar")) {
            //System.out.print("removeFileinPath()\n");
            ADBJarPath = removeFileinPath(ADBJarPath);
            directory.addElement(ADBJarPath);
        }
        
        jComboBoxSystemDrive.setModel(directory);
        jComboBoxSystemDrive.setSelectedIndex(0);
        jTreeSystem.addTreeSelectionListener(new TreeSelectionListener() {
            public void valueChanged(TreeSelectionEvent evt) {
                //JOptionPane.showMessageDialog(null, evt.getPath().toString());
                String pathPC = evt.getPath().toString();
                //output = output + formatPath(pathPC) + "\n";
                pathPCfile = formatPath(pathPC);
                WriteFileTMP(pathPCfile, 0);
            }
        });
        jTreeSystem.setModel(new FileTreeModel(new File(jComboBoxSystemDrive.getSelectedItem().toString())));
    }
    public static String runcommand(String command) {
        String out = "";
        String[] cc = command.split(" ");
        if (command.charAt(0) != '0') {
            //System.out.print(command.charAt(0));
            try {
                String line = "";
                ProcessBuilder pb = new ProcessBuilder(cc);
                pb.redirectErrorStream(true);
                Process process = pb.start();
                BufferedReader inStreamReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
                while ((line = inStreamReader.readLine()) != null) {
                    if (line.length() > 0) {
                        //output= output+ line+"\n";
                        out = out + line + "\n";
                        //output=output+line+"\n";
                        //jTextAreaStatus.setText(output);
                        //System.out.print(line+"\n");
                    }
                }
            } catch (IOException ex) {
                System.out.print(ex + "----ex11\n");
                output = output + ex + "----ex11\n";
                jTextAreaStatus.setText(output);
            }
        } else {
            //System.out.print(command.charAt(0));
            jTextAreaStatus.setText(output + "\nCommand is empty.");

        }
        return out;
    }
    public static String formatPath(String input) {
        //jTextAreaStatus.setText(output=output+"formatPath\n");
        if (osname.contains("Windows")) {
            input = input.replace(',', '\\');
            input = input.replace("\\\\ ", "\\");
            input = input.replace("[", "\"");
            input = input.replace("]", "\"");
            input = input.replace("\\ ", "\\");
        } else {
            input = input.replace("/, ", "/");
            input = input.replace(", ", "/");
            input = input.replace("[", "\"");
            input = input.replace("]", "\"");
            input = input.replace("\"", "");

        }
        return input;
    }
    public static String manualCommand(String input) {
        String out = "";

        return out;
    }
    public static void WriteFileTMP(String s, int index) {
        String[] arrayLine = ReadAllTMP();
        arrayLine[index] = s;
        try {
            FileOutputStream fstream = new FileOutputStream(path + ".adb", false);
            OutputStreamWriter out = new OutputStreamWriter(fstream, "utf-8");
            for (int i = 0; i < 6; i++) {
                out.write(arrayLine[i]);
                out.write(System.getProperty("line.separator"));
            }
            out.close();
            fstream.close();
        } catch (IOException ex) {
            System.out.print(ex + "----Normal----ex10\n");
            output = output + ex + "----ex10\n";
            jTextAreaStatus.setText(output);
        }
    }
    public static String ReadLineTMP(int index) {
        String[] arrayLine = new String[6];
        File adbfile = new File(path + ".adb");
        if (adbfile.isFile()) {
            try {
                FileInputStream fstream = new FileInputStream(adbfile);
                DataInputStream in = new DataInputStream(fstream);
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String strLine;
                int i = 0;
                while ((strLine = br.readLine()) != null && i < 6&&!"".equals(strLine)) {
                    arrayLine[i] = strLine;
                    i++;
                }
                in.close();
                fstream.close();
            } catch (IOException ex) {
                System.out.print(ex + "---ex8\n");
                output = output + ex + "---ex8\n";
                jTextAreaStatus.setText(output);
            }

        } else {
            output=output + "\nADB error. Maybe missing dll.";
            jTextAreaStatus.setText(output);
        }
        for (int i = 0; i < arrayLine.length; i++) {
            if (arrayLine[i] == null) {
                arrayLine[i] = "0";
            }
        }
        return arrayLine[index];
    }
    public static String[] ReadAllTMP() {
        String[] arrayLine = new String[6];
        File adbfile = new File(path + ".adb");
        if (adbfile.isFile()) {
            try {
                FileInputStream fstream = new FileInputStream(adbfile);
                DataInputStream in = new DataInputStream(fstream);
                BufferedReader br = new BufferedReader(new InputStreamReader(in));
                String strLine;
                int i = 0;
                while ((strLine = br.readLine()) != null && i < 6&&!"".equals(strLine)) {
                    arrayLine[i] = strLine;
                    i++;
                }
                in.close();
                fstream.close();
            } catch (IOException ex) {
                System.out.print(ex + "----ex5\n");
                output = output + ex + "----ex5\n";
                jTextAreaStatus.setText(output);
            }
            for (int i = 0; i < arrayLine.length; i++) {
                if (arrayLine[i] == null) {
                    arrayLine[i] = "0";
                }
            }
        }
        return arrayLine;
    }
    public static String readSavedDirectory() {
        String saveDirectory = ReadLineTMP(0);
        if (saveDirectory.length() > 1) {
            saveDirectory = saveDirectory.replace("\"", "");
            int len = saveDirectory.length();

            if (osname.contains("Windows")) {
                int i = len - 1;
                while (saveDirectory.charAt(i) != '\\') {
                    saveDirectory = saveDirectory.substring(0, i);
                    i--;
                }
            } else {
                int i = len - 1;
                while (saveDirectory.charAt(i) != '/') {
                    saveDirectory = saveDirectory.substring(0, i);
                    i--;
                }
            }
        }
        return saveDirectory;
    }
    public static void saveADBpath(){
        WriteFileTMP(pathPCfile, 1);
        //output = output + "Saved ADB path: " + pathPCfile;
        //jTextAreaStatus.setText(output);
        
        getADBfolderAndsetFullADBpath(readSavedADB());
    }
    public static String readSavedADB() {
        String saveDirectory = "";
        saveDirectory = ReadLineTMP(1);
        //output=output+saveDirectory+"\n";
        //jTextAreaStatus.setText(output);
        if (saveDirectory.length() > 2) {
            saveDirectory = saveDirectory.replace("\"", "");
            int len = saveDirectory.length();

            if (osname.contains("Windows")) {
                int i = len - 1;
                while (saveDirectory.charAt(i) != '\\') {
                    saveDirectory = saveDirectory.substring(0, i);
                    i--;
                }
            } else {
                int i = len - 1;
                while (saveDirectory.charAt(i) != '/') {
                    saveDirectory = saveDirectory.substring(0, i);
                    i--;
                }
            }
        }
        return saveDirectory;
    }
    public static String[] getLogicalDrivers() {
        File[] fileRoots = File.listRoots();
        String[] drivers = new String[fileRoots.length];
        for (int i = 0; i < drivers.length; i++) {
            drivers[i] = fileRoots[i].getPath();
        }
        return drivers;
    }
    public void Setcursor(int cursor){
    if(cursor==1){
    frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    }
    if(cursor==0){
        frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
    if(cursor==2){
        frame.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    }
    }
    public static void getADBfolderAndsetFullADBpath(String inputPath){
        
        if (osname.contains("Windows")) {
            adbVariable = "\""+inputPath + "adb.exe\"";
            aaptVariable = "\""+inputPath + "aapt.exe\"";
        } else {
            if(inputPath.charAt(0)=='/')inputPath=inputPath.substring(1);
output=output+adbVariable+"<<<adbVariable\n";
jTextAreaStatus.setText(output);
                int k=0;
                while(adbVariable.charAt(k)!='/'){
                    adbVariable = adbVariable.substring(k+1);
                    k++;
                }
                int j=0;
                while(adbVariable.charAt(j)!='/'){
                    adbVariable = adbVariable.substring(j+1);
                    j++;
                }
            adbVariable = "\""+inputPath+"./adb\"";
            aaptVariable ="\""+ inputPath+"./aapt\"";
output=output+adbVariable+"<<<adbVariable\n";
jTextAreaStatus.setText(output);
        }
    }
    public static String getSystemDirectoryOnSelect(){
        String PCDirectory="";
        Object object = jTreeSystem.getLastSelectedPathComponent();
        if( object!=null){
        File file = (File) object;
        if(file.isDirectory()){
            PCDirectory="\""+file.getAbsolutePath()+"\"";
        }
        else{
                PCDirectory=file.getAbsolutePath();
                PCDirectory = PCDirectory.replace("\"", "");
                if (PCDirectory.length() > 4) {
                    
                    int len = PCDirectory.length();

                    if (osname.contains("Windows")) {
                        int i = len - 1;
                        while (PCDirectory.charAt(i) != '\\') {
                            PCDirectory = PCDirectory.substring(0, i);
                            i--;
                        }
                        PCDirectory = "\""+PCDirectory.substring(0, i)+"\"";
                    } else {
                        int i = len - 1;
                        while (PCDirectory.charAt(i) != '/') {
                            PCDirectory = PCDirectory.substring(0, i);
                            i--;
                        }
                        PCDirectory = "\""+PCDirectory.substring(0, i)+"\"";
                    }
                }
        }
        }
        return PCDirectory;
    }
    public static String getSystemFileOnSelect(){
        String PCDirectory="";
        Object object = jTreeSystem.getLastSelectedPathComponent();
        if( object!=null){
        File file = (File) object;
        if(file.isDirectory()){
            PCDirectory="";
        }
        else{
            PCDirectory=file.getAbsolutePath();
            }
        }
        return PCDirectory;
    }
    public static String removeFileinPath(String inputPath){
        
        if(inputPath.length()>0){
        if (osname.contains("Windows")) {
            int i = inputPath.length() - 1;
            while (inputPath.charAt(i) != '\\') {
                inputPath = inputPath.substring(0, i);
                i--;
            }
        } else {
            int i = inputPath.length() - 1;
            while (inputPath.charAt(i) != '/') {
                inputPath = inputPath.substring(0, i);
                i--;
            }
        }
        }
        
        return inputPath;
    }
    public static String removeFileinPathUbuntu(String inputPath){
        
        if(inputPath.length()>0){
       
            int i = inputPath.length() - 1;
            while (inputPath.charAt(i) != '/') {
                inputPath = inputPath.substring(0, i);
                i--;
            }
        
        }
        
        return inputPath;
    }
    public static void exit(){
                        runcommand(adbVariable + " kill-server");
                    System.exit(0);
    }
    public class MyListRenderer extends DefaultListCellRenderer {

        private final HashMap theChosen = new HashMap();

        @Override
        public Component getListCellRendererComponent(JList list,
                Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index,
                    isSelected, cellHasFocus);

            if (isSelected) {
                theChosen.put(value, "chosen");
            }

            if (theChosen.containsKey(value)) {
                setForeground(Color.red);
            } else {
                setForeground(Color.black);
            }

            return (this);
        }
    }
    public class VisibleFrame extends SwingWorker<Void, String>{

        @Override
        protected Void doInBackground() throws Exception {
            if(adbViewState!=2){
            while(adbViewState==0){
                //System.out.print("sleep100\n");
                Thread.sleep(1000);
            }
            
            tray = tray + 1;
            frame.setVisible(true);
            frame.setState(frame.NORMAL);
            adbViewState=2;
            System.out.print("Done");
            }
            return null;
        }
    
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // private javax.swing.JCheckBox jCheckBoxAutoClick;
    // private javax.swing.JComboBox jComboBoxSystemDrive;
    // private javax.swing.JLabel jLabelBattery;
    // private javax.swing.JLabel jLabelBatteryValue;
    // private javax.swing.JLabel jLabelCPU;
    // private javax.swing.JLabel jLabelCPUValue;
    // private javax.swing.JLabel jLabelCheckDeviceConnect;
    // private javax.swing.JLabel jLabelCheckManifest;
    // private javax.swing.JLabel jLabelClearData;
    // private javax.swing.JLabel jLabelCloseApp;
    // private javax.swing.JLabel jLabelInstallAPK;
    // private javax.swing.JLabel jLabelListApps;
    // private javax.swing.JLabel jLabelOSK;
    // private javax.swing.JLabel jLabelRAM;
    // private javax.swing.JLabel jLabelRAMvalue;
    // private javax.swing.JLabel jLabelRunApp;
    // private javax.swing.JLabel jLabelScreenShot;
    // private javax.swing.JLabel jLabelSdcard0;
    // private javax.swing.JLabel jLabelSdcard0Value;
    // private javax.swing.JLabel jLabelSdcard1;
    // private javax.swing.JLabel jLabelSdcard1Value;
    // private javax.swing.JLabel jLabelSignal;
    // private javax.swing.JLabel jLabelSignalValue;
    // private javax.swing.JLabel jLabelTemp;
    // private javax.swing.JLabel jLabelTempValue;
    // private javax.swing.JLabel jLabelToLeft;
    // private javax.swing.JLabel jLabelToRight;
    // private javax.swing.JLabel jLabelUninstall;
    // private javax.swing.JLabel jLabelZoom;
    // private javax.swing.JPanel jPanelDecorated;
    // private javax.swing.JPanel jPanelDevice;
    // private javax.swing.JPanel jPanelDevicesStatus;
    // private javax.swing.JPanel jPanelFileExplorer;
    // private javax.swing.JPanel jPanelStatus;
    // private javax.swing.JPanel jPanelSystem;
    // private javax.swing.JPanel jPanelTransfer;
    // private javax.swing.JProgressBar jProgressBarDoInBackground;
    // private javax.swing.JScrollPane jScrollPaneDevice;
    // private javax.swing.JScrollPane jScrollPaneStatusLog;
    // private javax.swing.JScrollPane jScrollPaneSystem;
    // private javax.swing.JTextArea jTextAreaStatus;
    // private javax.swing.JTextField jTextFieldCommand;
    // private javax.swing.JTextField jTextFieldFilter;
    // private javax.swing.JTree jTreeDevice;
    // private javax.swing.JTree jTreeSystem;
    // private javax.swing.JPanel mainPanel;
    // End of variables declaration//GEN-END:variables
    
	public static javax.swing.JCheckBox jCheckBoxAutoClick;
    public static javax.swing.JComboBox jComboBoxSystemDrive;
	public static javax.swing.JLabel jLabelClearData;
    public static javax.swing.JLabel jLabelBattery;
    public static javax.swing.JLabel jLabelBatteryValue;
    public static javax.swing.JLabel jLabelCPU;
    public static javax.swing.JLabel jLabelCPUValue;
    public static javax.swing.JLabel jLabelOSK;
    public static javax.swing.JLabel jLabelRAM;
    public static javax.swing.JLabel jLabelRAMvalue;
    public static javax.swing.JLabel jLabelSignal;
    public static javax.swing.JLabel jLabelSignalValue;
    public static javax.swing.JLabel jLabelSdcard0;
    public static javax.swing.JLabel jLabelSdcard0Value;
    public static javax.swing.JLabel jLabelSdcard1;
    public static javax.swing.JLabel jLabelSdcard1Value;
    public static javax.swing.JLabel jLabelTemp;
    public static javax.swing.JLabel jLabelTempValue;
    public static javax.swing.JLabel jLabelCheckDeviceConnect;
    public static javax.swing.JLabel jLabelCheckManifest;
    public static javax.swing.JLabel jLabelCloseApp;
    public static javax.swing.JLabel jLabelInstallAPK;
    public static javax.swing.JLabel jLabelListApps;
    public static javax.swing.JLabel jLabelRunApp;
    public static javax.swing.JLabel jLabelScreenShot;
    public static javax.swing.JLabel jLabelToLeft;
    public static javax.swing.JLabel jLabelToRight;
    public static javax.swing.JLabel jLabelUninstall;
    public static javax.swing.JLabel jLabelZoom;
    public static javax.swing.JPanel jPanelDevicesStatus;
    public static javax.swing.JPanel jPanelDecorated;
    public static javax.swing.JPanel jPanelDevice;
    public static javax.swing.JPanel jPanelFileExplorer;
    public static javax.swing.JPanel jPanelStatus;
    public static javax.swing.JPanel jPanelSystem;
    public static javax.swing.JPanel jPanelTransfer;
    public static javax.swing.JProgressBar jProgressBarDoInBackground;
    public static javax.swing.JScrollPane jScrollPaneDevice;
    public static javax.swing.JScrollPane jScrollPaneStatusLog;
    public static javax.swing.JScrollPane jScrollPaneSystem;
    public static javax.swing.JTextArea jTextAreaStatus;
    public static javax.swing.JTextField jTextFieldCommand;
    public static javax.swing.JTextField jTextFieldFilter;
    public static javax.swing.JTree jTreeDevice;
    public static javax.swing.JTree jTreeSystem;
    public static javax.swing.JPanel mainPanel;

}
